from appium import webdriver
import time,traceback

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '8.1.0'
desired_caps['deviceName'] = 'test'
# desired_caps['app'] = r'F:\apk\toutiao.apk'
desired_caps['appPackage'] ='com.example.jcy.wvtest'
desired_caps['appActivity'] ='com.example.jcy.wvtest.MainActivity'
desired_caps['unicodeKeyboard']  = True
desired_caps['resetKeyboard']  = True
desired_caps['noReset'] = True
desired_caps['newCommandTimeout'] = 6000
#启动Remote RPC
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

time.sleep(3)
print(driver.contexts)
print(driver.current_context)
time.sleep(1)

driver.find_element_by_id('com.example.jcy.wvtest:id/navigation_dashboard').click()
time.sleep(1)
driver.find_element_by_id('com.example.jcy.wvtest:id/navigation_notifications').click()

driver.switch_to.context('WEBVIEW_com.example.jcy.wvtest')
time.sleep(3)
driver.find_element_by_id('index-kw').send_keys('松勤')
driver.find_element_by_id('index-bn').click()




